import pandas as pd
import numpy as np

data = pd.read_csv('result/result.csv')
median = pd.read_csv('result/median.csv')

data['r1'] = data['0']
data['r2'] = data.apply(lambda x: x['1'] - x['0'], axis=1)
data['r3'] = data.apply(lambda x: x['2'] - x['1'], axis=1)
data['r4'] = data.apply(lambda x: x['3'] - x['2'], axis=1)

array = data[['r1', 'r2', 'r3', 'r4']].values
result = pd.DataFrame(array, columns=['1', '2', '3', '4'])
result['label'] = data['label']
result['cox_result'] = np.argmax(array, axis=1) + 1
result['cox_correct'] = result.apply(lambda x: x['label'] == x['cox_result'], axis=1)
result['median'] = median['0.5']
result['median_correct'] = result.apply(lambda x: x['label'] == x['median'], axis=1)
result['median_1_correct'] = result.apply(lambda x: x['label'] == x['median'] + 1, axis=1)
print(result['cox_correct'].value_counts())
print(result['median_correct'].value_counts())
print(result['median_1_correct'].value_counts())

